package com.topvision.controller.zwan;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.topvision.model.zwan.CompanyPro;
import com.topvision.service.zwan.CompanyProService;
import com.topvision.util.PageUtils;
import com.topvision.util.Query;
import com.topvision.util.R;
import com.topvision.controller.AbstractController;

/**
 * 公司设置
 *
 * @author shengwm
 * @email 179653076@qq.com
 * @date 2018-04-18 13:27:44
 */
@RestController
@RequestMapping("zwan/companypro")
public class CompanyProController extends AbstractController {
    @Autowired
    private CompanyProService companyProService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("zwan/companypro:list")
    public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);

        List<CompanyPro> companyProList = companyProService.queryList(query);
        int total = companyProService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(companyProList, total, query.getLimit(), query.getPage());

        return R.success().put("page", pageUtil);
    }

    @RequestMapping("/findListByParam")
    @RequiresPermissions("zwan/companypro:list")
    public R findListByParam(@RequestParam Map<String, Object> params){

        List<CompanyPro> companyProList = companyProService.queryByParam(params);

        return R.success().put("companyProList", companyProList);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("zwan/companypro:info")
    public R info(@PathVariable("id") Long id){
        CompanyPro companyPro = companyProService.queryObject(id);
        return R.success().put("companyPro", companyPro);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("zwan/companypro:save")
    public R save(@RequestBody CompanyPro companyPro){
		companyProService.save(companyPro);
        return R.success();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("zwan/companypro:update")
    public R update(@RequestBody CompanyPro companyPro){
		companyProService.update(companyPro);
        return R.success();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("zwan/companypro:delete")
    public R delete(@RequestBody Long[] ids){
		companyProService.deleteBatch(ids);
        return R.success();
    }

}
